home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2001 October / macformat-108.iso / Shareware / Math scientific / PsyScript / scripts / ~Create a new Experiment\N / ~Create a new Experiment / N.rsrc / TEXT_2000_Source Text.txt < prev    next >
Encoding:
Text File  |  2001-07-06  |  3.6 KB  |  90 lines

  1.  
  2. tell application "PsyScript"
  3.     set fileHelper to load script file ("" & Psyscript base folder & "libraries:file.lib")
  4.     set proteus to "
  5. tell application \"PsyScript\"
  6.     activate
  7.     begin experiment
  8.     --load function libraries
  9.     set fileHelper to load script file (\"\" & Psyscript base folder & \"libraries:file.lib\")
  10.     set screen to load script file (\"\" & Psyscript base folder & \"libraries:screen.lib\")
  11.     set stairCase to load script file (\"\" & Psyscript base folder & \"libraries:stairCase.lib\")
  12.     --load stimuli
  13.     tell fileHelper to initialize()
  14.     tell fileHelper to     createNewSubjectID()
  15.     
  16.     --load permanent stimuli if you need them
  17.     --    load permanent stimulus \"fix\" as picture stimulus name 
  18.     
  19.     --noticed any response keys
  20.     set noticed of key \"Z\" to true
  21.     --set a mapping or label for each key (if you do not want the default)
  22.     set mapping of key \"Z\" to \"left\"
  23.     
  24.     --define your trial template (and any others you want (for instance a feedback trial)
  25.     set trialString to \"!e  + #100 !e !v 'hello' \"
  26.     
  27.     --load your stimuli from a file (assumed to be in a folder called \"" & fileHelper's pResourcesFolderName & "\" along side the script)
  28.     set thefile to \"stimfilename\" --tab delimited file of stimuli
  29.     --if it is not a full path, will assume it is in the default folder  
  30.     set stimList to readSpreadsheet(thefile) of fileHelper
  31.     --or just include them here like this
  32.     set stimList to {\"'hello'\", \"'goodbye'\"}
  33.     
  34.     repeat with aStim in stimList --while not completed
  35.         do trial ITTtrialString given {aStim}
  36.         if (subject response = \"left\") then
  37.             set gradedResponse to 1
  38.         else
  39.             set gradedResponse to 0
  40.         end if
  41.          tell filehelper to writespreadsheet(aStim, gradedResponse)
  42.     end repeat
  43.     
  44.     tell fileHelper to cleanup()
  45. end tell"
  46.     
  47.     activate
  48.     set newName to choose file name with prompt "choose a location and new name for your experiment" default name "myExperiment"
  49.     --try
  50.     set f to open for access newName with write permission
  51.     set eof f to 0
  52.     write proteus to f
  53.     close access f
  54.     set placeholder to the offset of ":" in (the reverse of every character of (newName as string)) as string
  55.     set theContainer to text 1 thru -(placeholder) of (newName as string)
  56.     set folderName to "Picts"
  57.     set whom to script editor as string
  58.     set tCreator to file creator of (info for (script editor as string))
  59.     set dlogStr to ""
  60.     tell application "Finder"
  61.         activate
  62.         if exists folder named (fileHelper's pResourcesFolderName) of folder theContainer then
  63.             set dlogStr to return & fileHelper's pResourcesFolderName & " folder already existed" & return
  64.         else
  65.             make folder at folder theContainer with properties {name:(fileHelper's pResourcesFolderName)}
  66.         end if
  67.         if exists folder named (fileHelper's pResultsFolderName) of folder theContainer then
  68.             if (fileHelper's pResourcesFolderName) is in dlogStr then
  69.                 set dlogStr to return & "Both " & (fileHelper's pResourcesFolderName) & " and " & (fileHelper's pResultsFolderName) & " folders already existed" & return
  70.             else
  71.                 set dlogStr to return & (fileHelper's pResultsFolderName) & " folder already existed" & return
  72.             end if
  73.         else
  74.             make folder at folder theContainer with properties {name:(fileHelper's pResultsFolderName)}
  75.         end if
  76.         set creator type of newName to tCreator
  77.         --set file type of newName to "osas"
  78.         reveal newName
  79.         if dlogStr = "" then
  80.             display dialog "I just created a script and folders for " & (fileHelper's pResourcesFolderName) & " " & (fileHelper's pResultsFolderName) & " files"
  81.         else
  82.             display dialog "I just created a script" & dlogStr
  83.         end if
  84.         open newName
  85.     end tell
  86. end tell
  87.  
  88. (* on error m number n
  89.     error m number n
  90. end try *)